package com.es.hr.shop;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

import com.es.business.area.AreaBiz;
import com.es.business.city.CityBiz;
import com.es.business.province.ProvinceBiz;
import com.es.common.CommonBiz;
import com.es.main.LoginUserBeen;
import com.opensymphony.webwork.interceptor.ServletRequestAware;
import com.opensymphony.xwork.ActionSupport;

public class ShopModifyInitAction extends ActionSupport
implements ServletRequestAware{
	 HttpServletRequest request;

	public void setServletRequest(HttpServletRequest paramHttpServletRequest) {
		// TODO Auto-generated method stub
		this.request = paramHttpServletRequest;
	}
	
	public String execute() throws Exception{
		String shopId = request.getParameter("shop_id");
		ShopBean sb = new ShopBiz().getShopById(shopId);
		request.setAttribute("shopBean", sb);
		request.setAttribute("areaList", new AreaBiz().getAreaList());
		request.setAttribute("provinceList", new ProvinceBiz().getProvinceByAreaCode(sb.getShop_area_code()));
		request.setAttribute("cityList", new CityBiz().getCityByProvinceCode(sb.getShop_province_code()));
		request.setAttribute("shangtypeList", new CommonBiz().getCommonByType("jingxiaoshangtype"));
		request.setAttribute("emp_area_code", sb.getShop_area_code());
		request.setAttribute("emp_province_code", sb.getShop_province_code());
		request.setAttribute("emp_city_code", sb.getShop_city_code());
		request.setAttribute("shop_jingxiaoshang_type", sb.getShop_jingxiaoshang_type());
		request.setAttribute("emp_ctm_id", sb.getShop_ctm_code());
		request.setAttribute("emp_ctm_name", sb.getShop_ctm_name());
		request.setAttribute("cityLevel", new CityBiz().getCityByCode(sb.getShop_city_code()).getCityLevel());

		return "success";
	}
	
	public ShopBean getShopBBean(HttpServletRequest request) throws SecurityException, ClassNotFoundException, IllegalArgumentException, IllegalAccessException{
		Field[] fds = Class.forName("com.es.hr.shop.ShopBean").getDeclaredFields();   
		ShopBean bean = new ShopBean();
		 
		  for(int i=0;i<fds.length;i++)   
		  {   
			  String d= fds[i].getName();
			  fds[i].set(bean, request.getParameter(d));
		  }
		  return bean;
	}
	 

}
